<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class WxOrder extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->common_model->checkpurview();
        $this->load->library('lib_pinyin');
    }

    //员工列表
    public function index()
    {

        $v = array();
        $data['status'] = 200;
        $data['msg'] = 'success';
        $list = $this->mysql_model->get_results(WX_ORDER, '(isDelete=0) order by id desc');
        foreach ($list as $arr => $row) {
            $v[$arr]['amount']        = (float)$row['iniamount'];
            $v[$arr]['barCode']       = $row['barCode'];
            $v[$arr]['id'] = intval($row['id']);
            $v[$arr]['orderSN'] = $row['orderSN'];
            $v[$arr]['userId'] = $row['userId'];
            if ($row['orderStatus'] == 1) {
                $v[$arr]['orderStatus'] = '已付款';
            } else {
                $v[$arr]['orderStatus'] = '未付款';
            }
            if ($row['payStatus'] == 1) {
                $v[$arr]['payStatus'] = '已付款';
            } else {
                $v[$arr]['payStatus'] = '未付款';
            }
            $v[$arr]['payName'] = $row['payName'];
            $v[$arr]['goodsAmount'] = $row['goodsAmount'];
            $v[$arr]['moneyPaid'] = $row['moneyPaid'];
            $v[$arr]['createTime'] = date('Y-m-d H:i:s', $row['createTime']);
//            $id=$row['id'];
//            $url=site_url();
            $v[$arr]['payTime'] = date('Y-m-d H:i:s', $row['payTime']);
//            $v[$arr]['payTime']="<a href='$url/order/order?action=getImage&id=$id'>查看详情</a>";
        }

        $data['data']['rows'] = $v;
        die(json_encode($data));
    }

    public function query() {
        $id = intval($this->input->get_post('id',TRUE));

        $sql='select * from '.WX_ORDER.' as wo LEFT JOIN '.WX_ORDER_GOODS.' as wr on wr.orderSN=wo.orderSN where wo.id='.$id;

        $data=$this->mysql_model->query(WX_ORDER,$sql,2);

        if (count($data)>0) {
            $v = array();
            foreach($data as $arr => $row){
                $v[$arr]['orderSN']            = $row['orderSN'];
                $v[$arr]['payTime']            = date('Y-m-d H:i:s',$row['payTime']);
                $v[$arr]['goodsName']            = $row['goodsName'];
                $v[$arr]['goodsPrice']            = $row['goodsPrice'];
                $v[$arr]['num']            = $row['num'];
            }
            $info['links']  = $v;
//            $this->load->view('wxorder-manage',$info);

            str_alert(200,'success',$info);
        }
        str_alert(-1,'没有数据');
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */